<?php
define('ROOT_PATH', dirname(__FILE__));


/**
 * 安装判断
 */
if (!file_exists(ROOT_PATH . "/data/install.lock") && is_dir(ROOT_PATH . "/install")) {
    @header("location: install");
    exit;
}

include(ROOT_PATH . '/eccore/ecmall.php');

/* 定义配置信息 */
ecm_define(ROOT_PATH . '/data/config.inc.php');


$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
$uachar = "/(nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|mobile)/i";
if((preg_match($uachar, $ua)))
{
//	$Loaction = 'mobile/index.php'.'?'.$_SERVER['QUERY_STRING'];
	$Loaction = '/mobile/index.php?app=qrcode&act=download';
    if (!empty($Loaction))
    {
        header("Location: $Loaction\n");
        exit;
    }
}

if ( empty($_SERVER['HTTP_USER_AGENT']) ) {
    $is_mobile = false;
} elseif ( strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false // many mobile devices (all iPhone, iPad, etc.)
    || strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false
    || strpos($_SERVER['HTTP_USER_AGENT'], 'Silk/') !== false
    || strpos($_SERVER['HTTP_USER_AGENT'], 'Kindle') !== false
    || strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') !== false
    || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== false
    || strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mobi') !== false ) {
    $is_mobile = true;
} else {
    $is_mobile = false;
}
if(!$is_mobile){
    $url = '/mobile/index.php?app=qrcode&act=pc';
    header("Location: $url\n");
    exit;
}

ECMall::startup(array(
    'default_app' => 'default',
    'default_act' => 'index',
    'app_root' => ROOT_PATH . '/app',
    'external_libs' => array(
        ROOT_PATH . '/includes/global.lib.php',
        ROOT_PATH . '/includes/libraries/time.lib.php',
        ROOT_PATH . '/includes/ecapp.base.php',
        ROOT_PATH . '/includes/plugin.base.php',
        ROOT_PATH . '/app/frontend.base.php',
        ROOT_PATH . '/includes/subdomain.inc.php',
    ),
));
?>
